package com.freesky.web.manager.shiro;

import com.freesky.common.dao.entity.User;
import com.freesky.common.enums.ResponseEnum;
import com.freesky.common.exception.MyException;
import org.apache.shiro.SecurityUtils;
/**
 *@author: 陈玉林
 *@date: 2019-01-10 9:09
 *@description: 获取当前用户信息
 */
public enum CurrentUser {

	INSTANCE;

	/**
	 * 获取当前用户
	 * @return
	 */
	public User getUser(){
		try {
			return (User)SecurityUtils.getSubject().getPrincipal();
		} catch (Exception e) {
			throw new MyException(ResponseEnum.SHIRO_ERROR_GET_USER, e, null);
		}
	}

}
